package com.travel.rabbit.controller.admin;

import com.travel.rabbit.service.CooperativeSpecialtyMerchantsService;
import com.travel.rabbit.entity.Result;
import com.travel.rabbit.dto.CooperativeSpecialtyMerchantsDTO;
import com.travel.rabbit.dto.MerchantsStatusDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (CooperativeSpecialtyMerchants)表控制层
 *
 * @author makejava
 * @since 2021-12-30 15:43:27
 */
@Api(tags = "商家模块")
@RestController
@RequestMapping("/merchant")
public class CooperativeSpecialtyMerchantsController {
    /**
     * 服务对象
     */
    @Resource
    private CooperativeSpecialtyMerchantsService merchantsService;

    @ApiOperation(value = "添加商家",tags = {"商家模块"})
    @PostMapping("/add")
    public Result add(@RequestBody CooperativeSpecialtyMerchantsDTO merchantsVO){
        return merchantsService.add(merchantsVO);
    }

    @ApiOperation(value = "修改商家",tags = {"商家模块"})
    @PostMapping("/update")
    public Result update(@RequestBody CooperativeSpecialtyMerchantsDTO merchantsVO){
        return merchantsService.update(merchantsVO);
    }

    @ApiOperation(value = "启用商家状态[后台管理员]",tags = {"商家模块"})
    @PostMapping("/enableMerchants")
    public Result enableMerchants(@RequestBody MerchantsStatusDTO merchantsVO){
        return merchantsService.updateMerchantsStatus(merchantsVO);
    }

    @ApiOperation(value = "禁用商家状态[后台管理员]",tags = {"商家模块"})
    @PostMapping("/disableMerchants")
    public Result disableMerchants(@RequestBody MerchantsStatusDTO merchantsVO){
        return merchantsService.updateMerchantsStatus(merchantsVO);
    }

    @ApiOperation(value = "启用商家状态",tags = {"商家模块"})
    @PostMapping("/openMerchants")
    public Result openMerchants(@RequestBody MerchantsStatusDTO merchantsVO){
        return merchantsService.closeMerchants(merchantsVO);
    }

    @ApiOperation(value = "根据商家编码查询商家信息",tags = {"商家模块"})
    @GetMapping("queryMerchantByNo")
    public Result queryMerchantByNo(@RequestParam("merchantsNo") String merchantsNo) {
        return this.merchantsService.queryMerchantByNo(merchantsNo);
    }

}